import os
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate

model = ChatOpenAI(
    model="deepseek-chat",
    openai_api_key=os.getenv("DEEPSEEK_API_KEY"),
    openai_api_base=os.getenv("DEEPSEEK_API_BASE")
)

#定义提示词模板
prompt = ChatPromptTemplate.from_messages([
    ("system", "你是一位专业的 {language} 程序员。"),
    ("human", "请编写一个函数，用于计算两个数 {operation} 的结果。")
])

chain = prompt | model

#使用提示词模板

response = chain.invoke({
    "language": "Python",
    "operation": "加法"
})

print(response.content)




